google.load('visualization', '1.0', {'packages':['corechart']});
	//google.setOnLoadCallback(drawChart);
jQuery(document).ready(function(){
	var tabs = jQuery('#escort-profile').tabs({
		cache: false
	});
	
	jQuery("#publish_option").change(function(){
		if(jQuery('#content-body div.alert').length){
			jQuery('#content-body div.alert').remove();
		}
		jQuery.post("./admin/be_escort/set_publish", {escort_id: jQuery('input[name="current_escort_id"]').val(),published:jQuery(this).val()},
			function(data) {
				if(data.result){
					jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				}else{
					jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
				}
			},"json"
		);
	});
	
	jQuery("#payment_option").change(function(){
		if(jQuery('#content-body div.alert').length){
			jQuery('#content-body div.alert').remove();
		}
		jQuery.post("./admin/be_escort/set_payment", {escort_id: jQuery('input[name="current_escort_id"]').val(),payment_option:jQuery(this).val()},
			function(data) {
				if(data.result){
					jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				}else{
					jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
				}
			},"json"
		);
	});
	jQuery("#locked_option").change(function(){
		if(jQuery('#content-body div.alert').length){
			jQuery('#content-body div.alert').remove();
		}
		jQuery.post("./admin/be_escort/set_locked", {escort_id: jQuery('input[name="current_escort_id"]').val(),locked_option:jQuery(this).val()},
			function(data) {
				if(data.result){
					jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
					location.reload();
				}else{
					jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
				}
			},"json"
		);
	});
	jQuery('.view-statistics').live('click', function(){
		jQuery.colorbox({
			href: jQuery(this).attr('href'),
			innerWidth: 700,
			innerHeight: 400
		});
		return false;
	});
});




function savePersionalInfo(){
	if(jQuery('#content-body div.alert').length){
		jQuery('#content-body div.alert').remove();
	}
	
	var params = {};
	jQuery("#personal-info-form") .find("select, input[type='checkbox'], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], textarea").each(function() {
		if(this.name){
			if(jQuery(this).attr('type') == 'checkbox'){
				if(jQuery(this).is(':checked')){
					params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
				}
			}else{
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
			}
		}
	});
	
	jQuery.post(SITE_URL + "admin/be_escort/personal/save", params,
		function(data) {
			if(data.result){
				jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				jQuery('#escort-profile').tabs( "load" , 1);
			}else{
				jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
			}
		},"json"
	);
}
function saveAppearance(){
	if(jQuery('#content-body div.alert').length){
		jQuery('#content-body div.alert').remove();
	}
	
	var params = {};
	jQuery("#appearance-form") .find("select, input[type='checkbox'], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], textarea").each(function() {
		if(jQuery(this).attr('type') == 'checkbox'){
			if(jQuery(this).is(':checked')){
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
			}
		}else{
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		}
	});
	
	jQuery.post("./admin/be_escort/appearance/save", params,
		function(data) {
			if(data.result){
				jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				jQuery('#escort-profile').tabs( "load" , 2);
			}else{
				jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
			}
		},"json"
	);
}
function saveService(){
	if(jQuery('#content-body div.alert').length){
		jQuery('#content-body div.alert').remove();
	}
	
	var params = {};
	jQuery("#service-form") .find("select, input[type='checkbox'], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], textarea").each(function() {
		if(jQuery(this).attr('type') == 'checkbox'){
			if(jQuery(this).is(':checked')){
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
			}
		}else{
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		}
	});
	
	jQuery.post("./admin/be_escort/service/save", params,
		function(data) {
			if(data.result){
				jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				jQuery('#escort-profile').tabs( "load" , 3);
			}else{
				jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
			}
		},"json"
	);
}
function saveRate(){
	if(jQuery('#content-body div.alert').length){
		jQuery('#content-body div.alert').remove();
	}
	
	var params = {};
	jQuery("#rate-form") .find("select, input[type='checkbox'], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], textarea").each(function() {
		if(jQuery(this).attr('type') == 'checkbox'){
			if(jQuery(this).is(':checked')){
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
			}
		}else{
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		}
	});
	
	jQuery.post("./admin/be_escort/rate/save", params,
		function(data) {
			if(data.result){
				jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				jQuery('#escort-profile').tabs( "load" , 4);
			}else{
				jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
			}
		},"json"
	);
}
function saveContactInfo(){
	if(jQuery('#content-body div.alert').length){
		jQuery('#content-body div.alert').remove();
	}
	
	var params = {};
	jQuery("#contact-info-form") .find("select, input[type='checkbox'], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], textarea").each(function() {
		if(jQuery(this).attr('type') == 'checkbox'){
			if(jQuery(this).is(':checked')){
				params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
			}
		}else{
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		}
	});
	
	jQuery.post("./admin/be_escort/contact/save", params,
		function(data) {
			if(data.result){
				jQuery('#content-body').prepend('<div class="alert success">'+ data.message+'</div>');
				jQuery('#escort-profile').tabs( "load" , 5);
			}else{
				jQuery('#content-body').prepend('<div class="alert error">'+ data.message+'</div>');
			}
		},"json"
	);
}
function confirmM(message, callback) {
	jQuery('#confirm').modal({
		closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
		position: ["20%",],
		overlayId: 'confirm-overlay',
		containerId: 'confirm-container', 
		onShow: function (dialog) {
			var modal = this;
			if(message != ''){
				jQuery('.message', dialog.data[0]).append(message);
			}
			// if the user clicks "yes"
			jQuery('.yes', dialog.data[0]).click(function () {
				// call the callback
				if (jQuery.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				modal.close(); // or $.modal.close();
			});
		}
	});
}